#ifndef RP2OPENGLRENDERER_H
#define RP2OPENGLRENDERER_H

#include <GL/glew.h>
#include <GL/glu.h>
#include <GL/wglew.h>

#include "Rp2OpenGLFrameBuffer.h"
#include "Rp2Renderer.h"
#include "Rp2Geometry.h"
#include "Rp2Texture.h"
#include "Rp2ShaderEffect.h"

namespace Rp2
{
class OpenGLRenderer : public Renderer
{
public:

protected:
	OpenGLRenderer(int iWinWidth, int iWinHeight);

	virtual void ClearBuffers();
	void InitializeState ();

    virtual void SetVProgramConstant (int eCType, int iBaseRegister,
        int iRegisterQuantity, float* afData);
    virtual void SetPProgramConstant (int eCType, int iBaseRegister,
        int iRegisterQuantity, float* afData);

	virtual void DrawElements();

    // Resource loading and releasing (to/from video memory).
    virtual void OnLoadVProgram (ResourceIdentifier*& rpkID, VertexProgram* pkVProgram);
    virtual void OnReleaseVProgram (ResourceIdentifier* pkID);
    virtual void OnLoadPProgram (ResourceIdentifier*& rpkID, PixelProgram* pkPProgram);
    virtual void OnReleasePProgram (ResourceIdentifier* pkID);
    virtual void OnLoadTexture (ResourceIdentifier*& rpkID, Texture* pkTexture) ;
    virtual void OnReleaseTexture (ResourceIdentifier* pkID);
    virtual void OnLoadVBuffer (ResourceIdentifier*& rkpID, const Attributes& rkIAttr,
		const Attributes& rkOAttr, VertexBuffer* pkVBuffer);
    virtual void OnReleaseVBuffer (ResourceIdentifier* pkID);
    virtual void OnLoadIBuffer (ResourceIdentifier*& rpkID, IndexBuffer* pkIBuffer);
    virtual void OnReleaseIBuffer (ResourceIdentifier* pkID);

    virtual void OnEnableVProgram (ResourceIdentifier* pkID);
    virtual void OnDisableVProgram (ResourceIdentifier* pkID);
    virtual void OnEnablePProgram (ResourceIdentifier* pkID);
    virtual void OnDisablePProgram (ResourceIdentifier* pkID);
    virtual void OnEnableTexture (ResourceIdentifier* pkID);
    virtual void OnDisableTexture (ResourceIdentifier* pkID);
    virtual void OnEnableVBuffer (ResourceIdentifier* pkID);
    virtual void OnDisableVBuffer (ResourceIdentifier* pkID);
    virtual void OnEnableIBuffer (ResourceIdentifier* pkID);
    virtual void OnDisableIBuffer (ResourceIdentifier* pkID);

    // Mappings from Ripple Engine constants to OpenGL enumerations.
    static GLenum ms_aeObjectType[Geometry::GT_MAX_QUANTITY];
    static GLenum ms_aeTextureMipmap[Texture::MAX_FILTER_TYPES];
    static GLenum ms_aeWrapMode[Texture::MAX_WRAP_TYPES];
    static GLenum ms_aeImageComponents[Image::IT_QUANTITY];
    static GLenum ms_aeImageFormats[Image::IT_QUANTITY];
    static GLenum ms_aeImageTypes[Image::IT_QUANTITY];
    static GLenum ms_aeSamplerTypes[SamplerInformation::MAX_SAMPLER_TYPES];
    static GLenum ms_aeMapTypes[3];

};

}

#endif